﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DataAnalyticsTools.Models
{
    /// <summary>
    /// 趋势分析结果
    /// </summary>
    public class TrendInfo
    {
        /// <summary>
        /// 检测方法
        /// </summary>
        public string Method { get; set; }

        /// <summary>
        /// 趋势斜率
        /// </summary>
        public float Slope { get; set; }

        /// <summary>
        /// 趋势强度 (R²决定系数)
        /// </summary>
        public float TrendStrength { get; set; }

        /// <summary>
        /// 趋势显著性
        /// </summary>
        public float Significance { get; set; }

        /// <summary>
        /// 趋势方向
        /// </summary>
        public TrendDirection Direction { get; set; }

        /// <summary>
        /// 拟合的线性值
        /// </summary>
        public float[] FittedValues { get; set; }

        /// <summary>
        /// 残差
        /// </summary>
        public float[] Residuals { get; set; }

        /// <summary>
        /// 检测到的变化点
        /// </summary>
        public List<ChangePoint> ChangePoints { get; set; }

        /// <summary>
        /// 分段趋势信息
        /// </summary>
        public List<SegmentTrend> SegmentTrends { get; set; }
    }

    /// <summary>
    /// 分段趋势信息
    /// </summary>
    public class SegmentTrend
    {
        /// <summary>
        /// 分段起始索引
        /// </summary>
        public int StartIndex { get; set; }

        /// <summary>
        /// 分段结束索引
        /// </summary>
        public int EndIndex { get; set; }

        /// <summary>
        /// 分段斜率
        /// </summary>
        public float Slope { get; set; }

        /// <summary>
        /// 分段趋势强度
        /// </summary>
        public float TrendStrength { get; set; }

        /// <summary>
        /// 分段趋势方向
        /// </summary>
        public TrendDirection Direction { get; set; }
    }

    /// <summary>
    /// 趋势方向枚举
    /// </summary>
    public enum TrendDirection
    {
        Increasing,    // 上升趋势
        Decreasing,    // 下降趋势
        NoTrend        // 无趋势
    }
}
